package edu.langnan.xiaoli.controller.common;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.constant.XiaoLiConstants;
import edu.langnan.xiaoli.core.dto.LostDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.LostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cql
 */
@RestController
@RequestMapping("common/lost")
public class CommonLostController extends BaseController {

    @Autowired
    private LostService lostService;

    /**
     * 分页查询 pageNum,pageSize,orderByColumn,isAsc
     *
     * @return
     */
    @GetMapping("list")
    public TableDataInfo listLost(@RequestParam(value = "lostType", defaultValue = "") String lostType) {
        // 分页
        startPage();
        List<LostDTO> result = lostService.findLostList(lostType, XiaoLiConstants.NO_STATUS, XiaoLiConstants.EMPTY_STU_ID);
        return getDataTable(result);
    }


    /**
     * 查找单个的 寻物启事/失物招领信息
     *
     * @param lostId
     * @return
     */
    @GetMapping("{lostId}")
    public AjaxResult findLostById(@PathVariable("lostId") Integer lostId) {
        LostDTO lostDTO = lostService.findLostById(lostId);
        return AjaxResult.success(lostDTO);
    }


}
